package yh.thread.system.shardingtest.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import yh.thread.system.shardingtest.service.ILongTransactionService;

/**
 * 测试大事务问题
 * @author: zyh
 * @date: 2024/12/16 11:07
 **/
@Service
public class LongTransactionServiceimpl implements ILongTransactionService {



    @Transactional(rollbackFor = Exception.class)
    @Override
    public void executeLongTransaction() {
        System.out.println("Transaction started...");
        try {
            Thread.sleep(10000); //堵塞10s
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println("Transaction ended...");
    }
}
